<!--
 @description  轻居客户详情
 @fileName LightCustomerDetail.vue
 @author zengqiongying
 @created 2023/05/04 11:16:51
-->
<template>
  <Detail :code="code" />
</template>

<script lang="ts">
  import { ref, getCurrentInstance } from 'vue'
  import { useRoute, onBeforeRouteLeave } from 'vue-router'
  import { useStore } from 'vuex'
  import Detail from './components/DetailInfo.vue'
  export default {
    name: 'LightCustomerDetail',
    components: { Detail },
    setup() {
      const instance = getCurrentInstance()
      const $store = useStore()
      const $route = useRoute()
      const code = ref(`${$route.query.code || ''}`)

      onBeforeRouteLeave((to, from) => {
        const instanceName = instance?.type?.name
        const toName: any = to.name
        if (['DealerCustomerAddress', 'DealerCustomerAccount'].includes(toName)) {
          $store.commit('routerKeep/resetCache', instanceName)
        } else {
          $store.commit('routerKeep/removeCache', instanceName)
        }
      })
      return {
        code
      }
    }
  }
</script>
<style lang="less" scoped></style>
